package de.popforge.audio 
{
	import __AS3__.vec.Vector;
	
	import de.popforge.audio.driver.AudioDriver;					

	/**
	 * @author Andre Michelle
	 */
	public class AudioEngine 
	{
		private var _driver: AudioDriver;
		private var _effects: Vector.<IAudioProcessor>;
		private var _generators: Vector.<IAudioProcessor>;

		public function AudioEngine()
		{						
			_driver = new AudioDriver( this );
			_generators = new Vector.<IAudioProcessor>();
			_effects = new Vector.<IAudioProcessor>();
		}

		public function addEffect( effect: IAudioProcessor ): void
		{
			_effects.push( effect );
		}
		
		public function addGenerator( generator: IAudioProcessor ):void
		{
			_generators.push( generator );
		}
		
		public function process( buffer: Vector.<Vector.<Number>> ): void
		{
			var i: int = 0;
			var n: int = _generators.length;
			for( ; i < n ; ++i )
				_generators[i].process( buffer );
			
			i = 0;
			n = _effects.length;			
			for( ; i < n ; ++i )
				_effects[i].process( buffer );
		}
		
		public function get driver(): AudioDriver
		{
			return _driver;
		}
	}
}
